package com.wgchao.amc.repository.base;

import com.wgchao.amc.entity.base.SysBaseUr;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @作者  wgchao
 * @时间 2019-10-30 
 * @用途  
 */
@Repository
public interface SysBaseUrRepository  extends JpaRepository<SysBaseUr, Long>, JpaSpecificationExecutor<SysBaseUr> {

    @Modifying
    @Query("update SysBaseUr set del = true , delTime = ?3 where userId = ?1 and groupId=?2")
    void updateUrToDel(Long userId, Long groupId, Date delTime);

    SysBaseUr findFirstByUserIdAndRoleIdAndGroupId(Long userId, Long roleId, Long groupId);

    List<SysBaseUr> findAllByUserIdAndDelIsFalse(Long userId);

    List<SysBaseUr> findAllByUserIdAndGroupIdAndDelIsFalse(Long userId, Long groupId);
}
